<%@ include file="/common/taglibs.jsp"%>

<head>
    <title><fmt:message key="clienteempresalist.title"/></title>
    <meta name="heading" content="<fmt:message key='clienteempresalist.heading'/>"/>    
</head>


<form:form commandName="clientebusqueda" method="post" action="topeslist.html?search=search" 
	 id="clientebusqueda" onsubmit="return onFormSubmit(this)">

<c:set var="buttons">        
    <input type="button" onclick="location.href='<c:url value="/mainMenu.html"/>'" value="<fmt:message key="button.done"/>"/>
</c:set>

<ul>
	<li>
	<label class="desc"><fmt:message key="common.filtros.busqueda"/></label>
	<div class="group" style="width: 300px">
		<div>
			<fmt:message key="cliente.empresa.razonsocial"/><br/>
			<form:input path="deNombreEmpresa" id="deNombreEmpresaID" maxlength="100" cssClass="text medium" />
			<br/>
			 
			<fmt:message key="cliente.empresa.ruc"/><br/>
			<form:input path="deRuc" id="deRucID" maxlength="11" cssClass="text medium" /><br/>

			<fmt:message key="cliente.empresa.linea.minima"/><br/>
			<form:input path="lineaCreditoMinima" id="lineaCreditoMinimaID" maxlength="11" cssClass="text medium" /><br/>

			<fmt:message key="cliente.empresa.linea.maxima"/><br/>
			<form:input path="lineaCreditoMaxima" id="lineaCreditoMaximaID" maxlength="11" cssClass="text medium" /><br/>
			
			<fmt:message key="cliente.empresa.tipo.linea"/><br/>	
			<form:select cssClass="text medium"
				id="tipoLineaCreditoID" path="tipoLineaCredito">
					<form:option value=""><fmt:message key="label.itemdefault"/></form:option>
					<form:option value="R"><fmt:message key="tipolineacredito.prepago"/></form:option>
					<form:option value="A"><fmt:message key="tipolineacredito.postpagoabierta"/></form:option>				
					<form:option value="C"><fmt:message key="tipolineacredito.postpagocerrada"/></form:option>				
			</form:select> 
			<br/>
			

			
			
			<fmt:message key="cliente.empresa.habilitado"/><br/>
				<form:select cssClass="text medium" id="stHabilitadoID" path="stHabilitado" >
					<form:option value="-"><fmt:message key="label.itemdefault"/></form:option>	
					<form:option value="Y"><fmt:message key="common.yes"/></form:option>	
					<form:option value="N"><fmt:message key="common.no"/></form:option>	
				</form:select>	
			<br/><br/>					
			<input type="submit"  class="button" value="<fmt:message key="button.search"/>"/>
		</div>
	</div>	
	</li>
</ul>
<c:out value="${buttons}" escapeXml="false" />

	<display:table name="empresas" cellspacing="0" cellpadding="0" requestURI="" 
		    id="clienteEmpresa" pagesize="30" class="table" style="width: 1000px" >
		    
		<display:column  titleKey="cliente.empresa.razonsocial">
			<a href="/clubpgnweb/topes/topesform.html?id=${clienteEmpresa.id}&amp;from=list" 
			> ${clienteEmpresa.deClienteEmpresa}</a>
		 </display:column>
		<display:column property="coRuc" titleKey="cliente.empresa.ruc"/>
		<display:column property="vaLineaCredito" titleKey="clienteempresaform.valor.linea"/>
		<display:column  titleKey="cliente.empresa.tipo.linea">
        	<c:choose>
          		<c:when test="${clienteEmpresa.coTipoLineaCredito eq 'R'}">
          			<fmt:message key='tipolineacredito.prepago'/> 
          		</c:when>
          		<c:when test="${clienteEmpresa.coTipoLineaCredito eq 'A'}">
          			<fmt:message key='tipolineacredito.postpagoabierta'/>
          		</c:when>          		
          		<c:when test="${clienteEmpresa.coTipoLineaCredito eq 'C'}">
          			<fmt:message key='tipolineacredito.postpagocerrada'/> 			
          		</c:when>          		
          		<c:otherwise>          			
          		</c:otherwise>
          	</c:choose>
		</display:column>
      
		<display:column titleKey="cliente.empresa.habilitado">
        	<c:choose>
          		<c:when test="${clienteEmpresa.habilitado eq 'Y'}">
          			<fmt:message key='common.yes'/>
          		</c:when>
          		<c:otherwise>
          			<fmt:message key='common.no'/>
          		</c:otherwise>
          	</c:choose>
		</display:column>
		
	</display:table>

</form:form>
<script>

   function onFormSubmit(objForm){

    	var vaLineaCreditoMinimaID 		= dwr.util.getValue('lineaCreditoMinimaID').trim();
		var vaLineaCreditoMaximaID 		= dwr.util.getValue('lineaCreditoMaximaID').trim(); 
		var nomLineaCreditoMinima = "<fmt:message key="cliente.empresa.linea.minima"/>";
		var nomLineaCreditoMaxima = "<fmt:message key="cliente.empresa.linea.maxima"/>";
    	if(vaLineaCreditoMinimaID != null && vaLineaCreditoMinimaID != ''){
    		if(isNaN(vaLineaCreditoMinimaID)){
    			 alert("<fmt:message key="common.validar.noNumero"><fmt:param value='"+nomLineaCreditoMinima+"'/></fmt:message>");
    			 document.getElementById("lineaCreditoMinimaID").focus();
    			 return false;
    		}
        }

    	if(vaLineaCreditoMaximaID != null && vaLineaCreditoMaximaID != ''){
    		if(isNaN(vaLineaCreditoMaximaID)){
    			alert("<fmt:message key="common.validar.noNumero"><fmt:param value='"+nomLineaCreditoMaxima+"'/></fmt:message>");
    			 document.getElementById("lineaCreditoMaximaID").focus();
    			 return false;
    		}
        }                    

    	  		
	  		return true;
	
    }
    </script>